//引入http模块
const http = require("http");
const url = require("url");
//设置主机名
var hostName = '127.0.0.1';
//设置端口
var port = 8080;
//创建服务
var server = http.createServer(function(req,res) {
	res.setHeader('Access-Control-Allow-Origin', '*')
	res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
	var url_info = url.parse(req.url, true);
	if(url_info.pathname === '/getUrl'){
		res.writeHead(200, {'Content-Type': 'text/plain'});
			res.end('node jssssssssssssssssssss');

	} else{
		req.pipe(res);
	}
});

server.listen(port,hostName,function(){
	console.log(`服务器运行在http://${hostName}:${port}`);
});